#define _CRT_SECURE_NO_WARNINGS 1
#include <vector>
using namespace std;
class Solution {
public:
    vector<int> twoSum(vector<int>& price, int target) {
        int left = 0;
        int right = price.size() - 1;
        vector<int> ret;
        while (left < right)
        {
            int leftp = price[left];
            int rightp = price[right];
            if (leftp + rightp > target)
            {
                --right;
            }
            else if (leftp + rightp < target)
            {
                ++left;
            }
            else
            {
                ret.push_back(price[left]);
                ret.push_back(price[right]);
                break;
            }
        }
        return ret;
    }
};